@extends('layouts.public')

@section('head')
    <link rel="stylesheet" href="{{cdn('js/plugins/webuploader/single.css')}}">
@endsection

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li><a href="{{route('admin.forum.forums')}}">论坛列表</a></li>
                        <li @if(!isset($user))class="active"@endif><a href="{{route('admin.forum.forums.add')}}">新增</a></li>
                        @if(isset($user))
                            <li class="active"><a href="#">编辑</a></li>
                        @endif
                    </ul>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="{{route('admin.forum.forums.save')}}" method="post" class="form-horizontal ajaxForm">
                            <input type="hidden" name="id" value="{{$user->id or 0}}"/>
                           
                            <div class="form-group">
                                <label class="col-sm-2 control-label">标题</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="title" @if(isset($user)) value="{{$user->title or ''}}"placeholder="请填写标题" @endif autocomplete="off"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">描述</label>
                                <div class="col-sm-3">
                                    <textarea  class="form-control" name="des" @if(isset($user)) value="{{$user->des or ''}}"placeholder="请填写描述" @endif ></textarea>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                    <button class="btn btn-white" type="button" id="backBtn">返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script src="{{cdn('js/plugins/webuploader/webuploader.nolog.min.js')}}"></script>
    <script src="{{cdn('js/plugins/webuploader/webuploader_public.js')}}"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            singleUpload({
                _token: '{{csrf_token()}}',
                type_key: 'FT_ONE_RESOURCE',
                item_id: '{{$user->id or 0}}',
                pick: 'shop_picker',
                boxid: 'shop_box',
                file_path: 'shop',
                file_id: 'shop_file_id'
            });
            $('#shop_box').find('.img-div>span').click(function () {
                sUploadDel($(this), 'avatar');
            });
            singleUpload({
                _token: '{{csrf_token()}}',
                type_key: 'FT_ONE_RESOURCE',
                item_id: '{{$user->id or 0}}',
                pick: 'zhizhao_picker',
                boxid: 'zhizhao_box',
                file_path: 'zhizhao',
                file_id: 'zhizhao_file_id'
            });
            $('#zhizhao_box').find('.img-div>span').click(function () {
                sUploadDel($(this), 'zhizhao');
            });
        });
    </script>
@endsection